package com.yhx.controller;

import com.yhx.iservice.IOrderService;
import com.yhx.pojo.OrderBo;
import com.yhx.utils.MessageConstant;
import com.yhx.utils.Result;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Reference
    private IOrderService orderService;

    @PostMapping
    public Result order(@RequestBody OrderBo orderBo){
        try {
            return orderService.doOrder(orderBo);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.ORDER_FAIL);
        }
    }
}